﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Installer;
using IniParser;

namespace Software_Installer
{
    class InstallerInterFace
    {
        private InstallerAPI _InstallerAPI;
        private List<string> _ToInstall;
        private List<string> _FinishedInstall;
        private List<string> _FormattedList;


        private static InstallerInterFace _InstallerInterface = null;
        public static InstallerInterFace Instance
        {
            get
            {
                if (_InstallerInterface == null)
                {
                    _InstallerInterface = new InstallerInterFace();
                }
                return _InstallerInterface;

            }
        }


        public InstallerInterFace()
        {
            _InstallerAPI = new InstallerAPI();
            _ToInstall = new List<string>();
            _FinishedInstall = new List<string>();
            _FormattedList = new List<string>();
        }

        public void SetToInstall(List<string> Toinstall)
        {
            _ToInstall = Toinstall;
        }
        public void AddToInstallList(string AddedInstall)
        {
            _ToInstall.Add(AddedInstall);
        }


        public List<string> GetInstallList()
        {
            return _ToInstall;
        }

        public void RunInstalls()
        {
            _InstallerAPI.InstallSoftware(_ToInstall);
        }
        public string GetCurrentAction()
        {
            return _InstallerAPI.GetCurrentInstalling();
        }

        public SectionDataCollection GetSections()
        {
            return _InstallerAPI.GetSections();
        }

        public void SendOneFinsh()
        {
            _FinishedInstall.Add(_ToInstall[0]);
            _ToInstall.RemoveAt(0);
        }

        public void Sendfinish(string name)
        {
            
            _FormattedList.Remove(name);
        }
        public void FormatList()
        {
            foreach (string oldstring in _ToInstall)
            {
                _FormattedList.Add(oldstring.Split('#')[1]);
            }
        }
        public List<string> newlist()
        {
            return _FormattedList;
        }

    }
}
